/*
 * Copyright (C) 2025-2025 Sermant Authors. All rights reserved.
 *
 *   Licensed under the Apache License, Version 2.0 (the "License");
 *   you may not use this file except in compliance with the License.
 *   You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *   Unless required by applicable law or agreed to in writing, software
 *   distributed under the License is distributed on an "AS IS" BASIS,
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *   See the License for the specific language governing permissions and
 *   limitations under the License.
 */

package io.sermant.demo.tagtransmission.jakarta.servlet5;

import jakarta.annotation.PostConstruct;
import jakarta.servlet.ServletContext;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * Servlet5.x Server
 *
 * @since 2025-05-22
 */
@SpringBootApplication
public class Servlet5ServerApplication {
    private static final Logger LOGGER = LoggerFactory.getLogger(Servlet5ServerApplication.class);

    @Autowired
    private ServletContext servletContext;

    /**
     * boot main method
     *
     * @param args boot args
     */
    @SuppressWarnings("uncommentedmain")
    public static void main(String[] args) {
        SpringApplication.run(Servlet5ServerApplication.class, args);
    }

    /**
     * check Servlet API Version
     */
    @PostConstruct
    public void checkServletVersion() {
        int majorVersion = servletContext.getMajorVersion();
        int minorVersion = servletContext.getMinorVersion();
        LOGGER.info("Servlet API Version: {}.{}", majorVersion, minorVersion);
    }
}
